﻿<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Web报表(B/S报表)演示 - 演示交叉表穿透查询明戏报表</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<script src="../CreateControl.js" type="text/javascript"></script>
	<script type="text/javascript">
        function window_onload() {
            btnRefresh_onclick();
        }

        function OnContentCellDblClick(Sender)
        {
            //交叉表应该从 RunningDetailGrid 取穿透数据
            var SelColumnName = ReportViewer.SelColumnName,
                RunningDetailGrid = ReportViewer.Report.RunningDetailGrid,
                recordset = RunningDetailGrid.Recordset,
                URL = getDrilldownBaseURL();
                
                if (SelColumnName === "City") {
                    URL += "&City=" + recordset.Fields.Item("City").AsString;
                }
                else if (SelColumnName === "CompanyName") {
                    URL += "&CompanyName=" + recordset.Fields.Item("CompanyName").AsString;
                }
                else if (SelColumnName === "Total") { //合计格
                    URL += "&CompanyName=" + recordset.Fields.Item("CompanyName").AsString;
                }
                else if (SelColumnName.indexOf("Subtotal") >= 0) { //小计格
                    //TDD...目前还没法做到Drilldown
                    URL += "&CompanyName=" + recordset.Fields.Item("CompanyName").AsString;
                }
                else { //交叉单元格
                    //TDD...目前还没法做到Drilldown
                    URL += "&CompanyName=" + recordset.Fields.Item("CompanyName").AsString;
                }
            
	        //根据参数打开对应明细报表
	        window.open(URL, "_blank");
        }
        
        //根据数据过滤参数重新显示报表
        function btnRefresh_onclick() {
            var BeginDate = document.getElementById("txtBeginDate").value,
                EndDate = document.getElementById("txtEndDate").value,
                dataURL = encodeURI("../../data/DataCenter.jsp?data=FilterCustomerProductCrosstab&BeginDate=" + BeginDate + "&EndDate=" + EndDate);

            ReportViewer.Stop(); //首先要停止报表运行
            ReportViewer.Report.ControlByName("SubTitle").AsStaticBox.Text = "日期范围：" + BeginDate + "至" + EndDate; //更新查询参数更新报表付标题，设置对应静态框的“Text”属性
            ReportViewer.dataURL = dataURL; //重置报表的数据URL
            ReportViewer.Start(); //重新启动生成报表
        }

        function getDrilldownBaseURL() {
            return "Detail.jsp?BeginDate=" + document.getElementById("txtBeginDate").value +
                "&EndDate=" + document.getElementById("txtEndDate").value;
        }
	</script>
    <style type="text/css">
        html,body {
            margin:0;
            height:100%;
        }
    </style>
</head>
<body style="margin:0" onload="window_onload()">
    <div style="">
        <span>开始日期：</span>
        <input id="txtBeginDate" type="text" value="1997-1-1" name="txtBeginDate" maxlength="20" style="width: 84px" />
        <span>结束日期：</span>
        <input id="txtEndDate" type="text" value="1997-12-31" name="txtEndDate" maxlength="20" style="width: 80px" />
        <input id="btnRefresh" onclick="return btnRefresh_onclick()" type="button" value="更新显示" name="btnRefresh" />
    </div>
    <div>
	    <script type="text/javascript"> 
		    CreateDisplayViewerEx("100%", "100%", "../../grf/SummaryToDetail/Crosstab.grf", "", true, 
		        "<param name=RowSelection value=false> <param name='OnContentCellDblClick' value='OnContentCellDblClick'>");
	    </script>
    </div>
</body>
</html>
